lib/checkout: Do UNION_FILES via atomic renameat()
authorColin Walters <walters@verbum.org>
Wed, 13 Sep 2017 20:22:18 +0000 (16:22 -0400)
committerAtomic Bot <atomic-devel@projectatomic.io>
Fri, 15 Sep 2017 16:44:00 +0000 (16:44 +0000)
commitc32f234e9a63396725e98792dc2c4373504b44ac
treecea1957dfc66418b3b432addcc047abdbfbc3ce9
parent74996202544883ae2dc49407f44b05a09f5bc311
lib/checkout: Do UNION_FILES via atomic renameat()

I was looking at fixing an `rpm-ostree livefs` bug where we need to replace
`/usr/lib/passwd`. It's obviously bad if that temporarily disappears ðŸ˜‰. My plan
is to do a subpath checkout of just `/usr/lib/{passwd,group}`.

Make this atomic (i.e. file always exists) by changing the logic to create a
temporary link in repo/tmp, then rename() it into place.

A bonus here is we kill one of the very few (only?) non-error-cleanup i.e.
"non-linear" `goto`s in the ostree codebase.

Closes: #1171
Approved by: jlebon
src/libostree/ostree-repo-checkout.c